package main

import (
	"bufio"
	"fmt"
	"strings"
)

const input = "It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming; but who does actually strive to do the deeds; who knows great enthusiasms, the great devotions;"

func main() {

	bucket := make([][]string, 12, 12)
	scanner := bufio.NewScanner(strings.NewReader(input))
	scanner.Split(bufio.ScanWords)
	for scanner.Scan() {
		text := scanner.Text()
		//fmt.Println(text)
		index := hashBucket(text, 12)
		s := bucket[index]
		//s[len(s)] = text
		s = append(s, text)
		bucket[index] = s
	}
	fmt.Println(bucket)
}

func hashBucket(word string, bucketSize int) int {
	var sum int
	for _, v := range word {
		sum += int(v)
	}
	return sum % bucketSize
}
